﻿using System;

namespace jQueryLib
{
    public abstract class Callbacks
    {
        /// <summary>
        /// Ensures the callback list can only be fired once (like a Deferred).
        /// </summary>
        [EvalAtCompile]
        public const string Once = "once";

        /// <summary>
        /// Keep track of previous values and will call any callback added after the list has been fired right away with the latest "memorized" values (like a Deferred).
        /// </summary>
        [EvalAtCompile]
        public const string Memory = "memory";

        /// <summary>
        /// Ensures a callback can only be added once (so there are no duplicates in the list).
        /// </summary>
        [EvalAtCompile]
        public const string Unique = "unique";

        /// <summary>
        /// Interrupts callings when a callback returns false.
        /// </summary>
        [EvalAtCompile]
        public const string StopOnFalse = "stopOnFalse";

        /// <summary>
        /// Add a callback to callback list.
        /// </summary>
        /// <param name="del"></param>
        public abstract void Add(Delegate del);

        /// <summary>
        /// Remove a callback from callback list.
        /// </summary>
        /// <param name="del"></param>
        public abstract void Remove(Delegate del);

        /// <summary>
        /// Disable a callback list from doing anything more.
        /// </summary>
        public abstract void Disable();

        /// <summary>
        /// Determine if the callbacks list has been locked.
        /// </summary>
        /// <returns></returns>
        public abstract bool Locked();

        /// <summary>
        /// Lock a callback list in its current state.
        /// </summary>
        public abstract void Lock();

        /// <summary>
        /// Determine whether a supplied callback is in a list
        /// </summary>
        /// <param name="del"></param>
        /// <returns></returns>
        public abstract bool Has(Delegate del);

        /// <summary>
        /// Determine if the callbacks have already been called at least once.
        /// </summary>
        /// <returns></returns>
        public abstract bool Fired();

        /// <summary>
        /// Call all of the callbacks with the given arguments
        /// </summary>
        /// <param name="args"></param>
        public abstract void Fire(params object[] args);

        /// <summary>
        /// Call all callbacks in a list with the given context and arguments.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="args"></param>
        public abstract void FireWith(object context, object[] args);

        /// <summary>
        /// Remove all of the callbacks from a list.
        /// </summary>
        public abstract void Remove();
    }
}
